package com.Endurancer.manager.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.Endurancer.common.annotation.Log;
import com.Endurancer.common.core.controller.BaseController;
import com.Endurancer.common.core.domain.AjaxResult;
import com.Endurancer.common.enums.BusinessType;
import com.Endurancer.manager.domain.FamousQuotes;
import com.Endurancer.manager.service.IFamousQuotesService;
import com.Endurancer.common.utils.poi.ExcelUtil;
import com.Endurancer.common.core.page.TableDataInfo;

/**
 * 名言Controller
 *
 * @author Endurancer
 * @date 2025-02-02
 */
@RestController
@RequestMapping("/manager/quotes")
public class FamousQuotesController extends BaseController
{
    @Autowired
    private IFamousQuotesService famousQuotesService;

    /**
     * 查询名言列表
     */
//    @PreAuthorize("@ss.hasPermi('manager:quotes:list')")
    @GetMapping("/list")
    public TableDataInfo list(FamousQuotes famousQuotes)
    {
        startPage();
        List<FamousQuotes> list = famousQuotesService.selectFamousQuotesList(famousQuotes);
        return getDataTable(list);
    }

    /**
     * 导出名言列表
     */
    @PreAuthorize("@ss.hasPermi('manager:quotes:export')")
    @Log(title = "名言", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FamousQuotes famousQuotes)
    {
        List<FamousQuotes> list = famousQuotesService.selectFamousQuotesList(famousQuotes);
        ExcelUtil<FamousQuotes> util = new ExcelUtil<FamousQuotes>(FamousQuotes.class);
        util.exportExcel(response, list, "名言数据");
    }

    /**
     * 获取名言详细信息
     */
    @PreAuthorize("@ss.hasPermi('manager:quotes:query')")
    @GetMapping(value = "/{quoteId}")
    public AjaxResult getInfo(@PathVariable("quoteId") Long quoteId)
    {
        return success(famousQuotesService.selectFamousQuotesByQuoteId(quoteId));
    }

    /**
     * 新增名言
     */
    @PreAuthorize("@ss.hasPermi('manager:quotes:add')")
    @Log(title = "名言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FamousQuotes famousQuotes)
    {
        return toAjax(famousQuotesService.insertFamousQuotes(famousQuotes));
    }

    /**
     * 修改名言
     */
    @PreAuthorize("@ss.hasPermi('manager:quotes:edit')")
    @Log(title = "名言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FamousQuotes famousQuotes)
    {
        return toAjax(famousQuotesService.updateFamousQuotes(famousQuotes));
    }

    /**
     * 删除名言
     */
    @PreAuthorize("@ss.hasPermi('manager:quotes:remove')")
    @Log(title = "名言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{quoteIds}")
    public AjaxResult remove(@PathVariable Long[] quoteIds)
    {
        return toAjax(famousQuotesService.deleteFamousQuotesByQuoteIds(quoteIds));
    }
}
